package com.example.myjava.controller;

import org.springframework.web.bind.annotation.*;

import java.util.HashMap;

@RestController
public class HelloController {
    @GetMapping("/hello")
    public String hello(){
        return "helloword springboot"+nameages.toString();
    }
    private static HashMap<String,Integer> nameages=new HashMap<>();

    @PostMapping("/hello")
    public String hello(String name,int age){
        nameages.put(name,age);
        return "add name="+name+"age="+age;
    }
//    @PostMapping("/hello2")
//    public String hello2(String name,int age){
//        nameages.put("lu",22);
//        return "add name"+nameages.get("name")+nameages.get("age")+nameages.get("lu");
//    }
//    @PostMapping("/hello3")
//    public String hello3(){
//        nameages.put("lu",22);
//        return "add name"+nameages.get("leby");
//    }

    @PutMapping("/hello")
    public String hello1(String name,int age){
        nameages.replace(name,age);
        return "update name="+name+"age="+age;
    }
    @DeleteMapping("/hello/{name}")
    public String hellodel(@PathVariable String name){
        nameages.remove(name);
        return "delete name="+name;
    }
}
